#ifndef _DUCKS_CPLAYER_H_
#define _DUCKS_CPLAYER_H_

#include "cdeadline.h"
#include "cstate.h"
#include "HMM.h"

#include <vector>

using namespace std;

namespace ducks
{

class CPlayer
{
private:

    HMM **duckModels;
    HMM **speciesModels;
    vector<int> *obs;
    int nextDuck;
    int ducksKilled;
    int speciesIdentified;
    float blackProb;
    float blackProbGuess;

    /*
    * Gives each type of observation a unique integer
    *
    *\param obs The observation that wants to be translated
    *\return A hash code for the observation
    *         0 -> H: EAST, ACC | V: UP  , ACC 
    *         1 -> H: EAST, ACC | V: UP  , KS  
    *         2 -> H: EAST, ACC | V: DOWN, ACC 
    *         3 -> H: EAST, ACC | V: DOWN, KS  
    *         4 -> H: EAST, KS  | V: UP  , ACC 
    *         5 -> H: EAST, KS  | V: UP  , KS  
    *         6 -> H: EAST, KS  | V: DOWN, ACC 
    *         7 -> H: EAST, KS  | V: DOWN, KS  
    *         8 -> H: WEST, ACC | V: UP  , ACC 
    *         9 -> H: WEST, ACC | V: UP  , KS  
    *         10 -> H: WEST, ACC | V: DOWN, ACC 
    *         11 -> H: WEST, ACC | V: DOWN, KS  
    *         12 -> H: WEST, KS  | V: UP  , ACC 
    *         13 -> H: WEST, KS  | V: UP  , KS  
    *         14 -> H: WEST, KS  | V: DOWN, ACC 
    *         15 -> H: WEST, KS  | V: DOWN, KS  
    *         16 -> H: EAST, ACC | V: Stopped   
    *         17 -> H: EAST, KS  | V: Stopped   
    *         18 -> H: WEST, ACC | V: Stopped   
    *         19 -> H: WEST, KS  | V: Stopped   
    *         20 -> H: Stopped   | V: DOWN, ACC 
    *         21 -> H: Stopped   | V: DOWN, KS  
    *         22 -> H: Stopped   | V: UP  , ACC 
    *         23 -> H: Stopped   | V: UP  , KS  
    *         24 -> H: Stopped   | V: Stopped 
    */
    int mapObsToInt(CAction obs);

    //Alternative mapping
    int mapObsToInt2(CAction obs);

    //Alternative mapping
    CAction *mapIntToObs2(int hash, int bird, EMovement last);

    /*
    * Given a hash code, returns an action that represents the corresponding
    * shot that should be returned to the server
    *
    *\param hash Integer returned by an HMM used to represent Duck hunt
    *\param bird Number of the bird that will be shot
    *\return An action object that represents taking a shot on the bird given
    */
    CAction *mapIntToObs(int hash, int bird);

public:
    ///constructor
    
    ///There is no data in the beginning, so not much should be done here.
    CPlayer();

    ///shoot!

    ///This is the function where you should do all your work.
    ///
    ///you will receive a variable pState, which contains information about all ducks,
    ///both dead and alive. Each duck contains all past actions.
    ///
    ///The state also contains the scores for all players and the number of
    ///time steps elapsed since the last time this function was called.
    ///
    ///Check their documentation for more information.
    ///\param pState the state object
    ///\param pDue time before which we must have returned. To check how much 
    ///time we have left you can use \p pDue.RemainingUntil(), which returns the remaining time
    ///in milliseconds.
    ///\return the position we want to shoot at, or cDontShoot if we 
    ///prefer to pass
    CAction Shoot(const CState &pState,const CDeadline &pDue);

    ///guess the species!

    ///This function will be called at the end of the game, to give you
    ///a chance to identify the species of the surviving ducks for extra
    ///points.
    ///
    ///For each alive duck in the vector, you must call the SetSpecies function,
    ///passing one of the ESpecies constants as a parameter
    ///\param pDucks the vector of all ducks. You must identify only the ones that are alive
    ///\param pDue time before which we must have returned
    void Guess(std::vector<CDuck> &pDucks,const CDeadline &pDue);

    ///This function will be called whenever you hit a duck.
    ///\param pDuck the duck index
    ///\param pSpecies the species of the duck (it will also be set for this duck in pState from now on)    
    void Hit(int pDuck,ESpecies pSpecies);


};
/*namespace ducks*/ }

#endif
